package com.chen.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.common.Result;
import com.chen.mapper.ArticleMapper;
import com.chen.mapper.LikesMapper;
import com.chen.mapper.UserMapper;
import com.chen.pojo.Article;
import com.chen.pojo.Likes;
import com.chen.service.LikesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author chen
 */
@Service
public class LikesServiceImpl extends ServiceImpl<LikesMapper, Likes> implements LikesService {


    @Resource
    private LikesMapper likesMapper;


    @Resource
    private ArticleMapper articleMapper;

    public Result addLikes(Likes likes) {
        likes.setFlag(1);
        likes.setTime(new Date());

        return Result.success(likesMapper.insert(likes));
    }

    public Result deleteLikes(int foreignId, String liker) {
        return Result.success(likesMapper.deleteLikes(foreignId, liker));
    }


    public Result selectLikes(int foreignId, String liker) {
        return Result.success(likesMapper.selectLikes(foreignId, liker));
    }


}
